﻿
@{
    Layout = null;
}

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>存货选择</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="proCode" placeholder="产品编码" autocomplete="off" class="layui-input" id="proCode" style="width:150px;float:left">
                                <input type="text" name="proName" placeholder="产品名称" autocomplete="off" class="layui-input" id="proName" style="width: 180px; float: left;margin-left:6px;margin-right:6px;">
                                <input type="text" name="spec" placeholder="规格型号" autocomplete="off" class="layui-input" id="spec" style="width: 180px; float: left;margin-left:6px;margin-right:6px;">
                                <button class="layui-btn" lay-filter="sreach" id="btnQuery" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                                <button class="layui-btn" lay-filter="sreach" id="btnSure" type="button" onclick="sureChoose()"><i class="layui-icon">&#xe679;</i>确认</button>
                            </div>


                        </form>
                    </div>

                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                        <input type="hidden" name="svalue" id="svalue" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    var single = "1";
    var typeCode = "";
    $(function () {
        single = getUrlVariable("isSingle");
        typeCode = getUrlVariable("typeCode");
        loadData();
    });
    function loadData() {
        var conditon = JSON.stringify(FormToJson("qForm"));
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#list'
            , url: "../Basis/GetDataList?condition=" + conditon + "&dataType=ven&limit=200&typesCode="+typeCode
            , skin: 'row' //表格风格
            , even: true
            , page: false //是否显示分页
            , height: $(document).height() - $('#list').offset().top - 20
            , cols: [[ //标题栏
              { type: 'checkbox' }
            , { field: 'proCode', title: '存货编码', width: 180 }
            , { field: 'proName', title: '存货名称', width: 120 } //空列
            , { field: 'spec', title: '规格型号', width: 150 }
            , { field: 'c_tssx', title: '特殊属性', width: 120 } 
            ]]
            });
            //监听工具条
            table.on('checkbox(list)', function (obj) {
                var data = obj.data;
              
                //为父窗口input赋值
                $("#svalue").val("");
                var checkStatus = table.checkStatus('list');
                var infos = "";
                for (var i = 0; i < checkStatus.data.length; i++) {
                    infos = infos + JSON.stringify(checkStatus.data[i]) + ";";
                }
                $("#svalue").val(infos.substr(0, infos.length - 1));
            });

        });
    }

    function sureChoose() {
        var value = $("#svalue").val();

        if (value == "") {
            layer.msg("没有选择任何数据"); return;
        } else {
            if (single == "1") {
                if (value.indexOf(";") >= 0) {
                    layer.msg("请选择一条数据记录"); return;
                }
            }
            parent.$('#selectProduct').val(value);
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        }

    }
</script>
